package com.syf.controller.RJController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syf.domain.store.BsNotice;
import com.syf.domain.store.BsSoftwareIncluded;
import com.syf.model.R;
import com.syf.service.BsNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author syf
 * @create 2022-02-08 9:27
 */
@RestController
@RequestMapping("/bsNotice")
@Api(tags = "系统公告(资讯)")
public class BsNoticeController {

    @Autowired
    private BsNoticeService bsNoticeService;


    @PostMapping("/addNotice")
    @ApiOperation(value = "添加资讯")
    public R addNotice(@RequestBody @Validated BsNotice bsNotice){
        boolean save = bsNoticeService.save(bsNotice);
        if(save){
            return R.ok("新增成功");
        }
        return  R.fail("新增失败");
    }


    @PostMapping("/noticeList")
    @ApiOperation(value = "分页条件查询--资讯列表【标题】")
    public R<Page<BsNotice>> findByPage(Page<BsNotice> page , String title ){
        Page<BsNotice> pageData =  bsNoticeService.findByPage(page,title) ;
        return R.ok(pageData);
    }


    @PostMapping("/updateNotice")
    @ApiOperation(value = "查看应用审核详细")
    public R<BsNotice> updateNotice(@RequestBody BsNotice bsNotice){
        boolean update = bsNoticeService.updateById(bsNotice);
        if(update){
            return R.ok("修改成功");
        }
        return  R.fail("修改失败");
    }
}
